﻿using Aker.DevTeam;
using Aker.Uretim;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using Extensions;
using System;
using System.Data;


namespace Aker.Product
{
    public partial class YeniImalatKarti3 : XForm
    {

        DataTable dtHammadde = null;
        DataTable dtRecete = null;
        DataTable dtMaliyet = null;

        int BazProductId;
        string bazArtikel;
        int UretimTipi = 0;
        int POrderLinesId;
        int StokKartiTipi = 1;


        public delegate void ProductInsertedEventHandler(int ProductId, string Artikel, int StokKartiTipi);
        public event ProductInsertedEventHandler ProductInserted;
        public YeniImalatKarti3()
        {
            InitializeComponent();
        }

        public YeniImalatKarti3(int StokKartiTipi)
        {
            InitializeComponent();
            this.StokKartiTipi = StokKartiTipi;
           
        }

        public YeniImalatKarti3(string bazArtikel, int bazProductId, int uretimTipi, decimal qty, int pOrderLinesId)
        {
            InitializeComponent();

            teQty.EditValue = qty;
            teQty.Visible = false;

            this.BazProductId = bazProductId;
            this.bazArtikel = bazArtikel;

            this.UretimTipi = uretimTipi;
            this.POrderLinesId = pOrderLinesId;

            string[] g20 = new string[] { "20.", "10.", "5000", "7000", "8000", "9000", "9500" };
            string[] g11 = new string[] { "11.", "12.", "30." };
            bool found = false;

           
        }


        private void seHarman_EditValueChanged(object sender, System.EventArgs e)
        {

        }

        private void StokKarti_Load(object sender, EventArgs e)
        { 
            //tab.ShowTabHeader = DevExpress.Utils.DefaultBoolean.False;
             

            if (Data.DB.Currency.Rows.Count == 0)
                Data.TAM.CurrencyTableAdapter.Fill(Data.DB.Currency);


            switch (StokKartiTipi)
            {
                case 1:
                   
                    break;
                case 2:
                    Load11();
                    break;
                case 3:
                    break;
                case 4:
                    break;
            }
            //       int x = gv1.Container.Components.Count;
        }

 
        #region 11
        private void Load11()
        {
            //gvMaliyet11.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;
            //dtHammadde = Data.DM.ExecuteDataSet("GetHammaddeStok").Tables[2];

            //DataTable dtIp = dtHammadde.Select("HammaddeId < 1000000").CopyToDataTable();
            //gleIp1.Properties.Assign(Utility.GetAutoCompGLE(dtIp, "Hammadde", "HammaddeId"));
            //gleIp2.Properties.Assign(Utility.GetAutoCompGLE(dtIp, "Hammadde", "HammaddeId"));
            //gleIp3.Properties.Assign(Utility.GetAutoCompGLE(dtIp, "Hammadde", "HammaddeId"));
            //gleIp4.Properties.Assign(Utility.GetAutoCompGLE(dtIp, "Hammadde", "HammaddeId"));

            //if (Data.DB.Product.Rows.Count == 0)
            //    Data.TAM.ProductTableAdapter.Fill(Data.DB.Product);

            //if (Data.DB.OrmeMakinesi.Rows.Count == 0)
            //    Data.TAM.OrmeMakinesiTableAdapter.Fill(Data.DB.OrmeMakinesi);

            //if (Data.DB.Currency.Rows.Count == 0)
            //    Data.TAM.CurrencyTableAdapter.Fill(Data.DB.Currency);
            //gleMakineCinsi.Properties.Assign(Utility.GetAutoCompGLE(Data.DB.OrmeMakinesi, "OrguCinsi", "OrmeMakinesiId"));


            //DataTable dtProduct = Data.DB.Product.DefaultView.ToTable(true, "ProductId", "Article", "Weight", "ToleranceWeight", "Width", "ToleranceWidth", "Composition", "ToleranceComposition", "Design", "PartiNo");
            //gleBazArtikel11.Properties.Assign(Utility.GetAutoCompGLE(dtProduct, "Article", "ProductId"));
            //if (bazArtikel != null)
            //{
            //    gleBazArtikel11.EditValue = dtProduct.Select("Article = '" + bazArtikel + "'")[0]["ProductId"];
            //    teQty.Visible = false;
            //}
            //else
            //    teQty.Visible = true;


            //if (BazProductId > 0)
            //    LoadProductDetail11();
            //else
            //    InitMaliyetGv(null);

            //cmbUretimTipi11.SelectedIndex = UretimTipi;
            //UretimTipiChanged11();

            //cmbGrup11.SelectedIndex = 0;
            //cmbKompozisyon11.SelectedIndex = 0;


            //cmbUretimTipi11.SelectedIndexChanged += cmbUretimTipi_SelectedIndexChanged;
        }

        private void Save11(AkerDB.ProductDetayRow drDetay)
        {
            //drDetay.ProductGrupId = cmbGrup11.SelectedIndex + 1;
            //drDetay.KompozisyonId = cmbKompozisyon11.SelectedIndex + 1;

            //drDetay.FinishGr = seFinalGramaj11.EditValue.ToIntNN();
            //if (drDetay.FinishGr < 1)
            //    drDetay.SetFinishGrNull();

            //drDetay.GirisGr = seGirisGramaj11.EditValue.ToIntNN(); ;
            //if (drDetay.GirisGr < 1)
            //    drDetay.SetGirisGrNull();

            //drDetay.Fire = seFire11.EditValue.ToIntNN();
            //if (drDetay.Fire == 0)
            //    drDetay.SetFireNull();

            //drDetay.SIKLIK = txtSıklık11.Text;
            //if (drDetay.SIKLIK == "")
            //    drDetay.SetSIKLIKNull();

            //drDetay.Aciklama = txtAciklama11.Text;
            //if (drDetay.Aciklama == "")
            //    drDetay.SetAciklamaNull();

            //drDetay.Dink = chkDink11.Checked;
            //drDetay.Sardon = cmbSardon11.SelectedIndex + 1;
            //drDetay.RamId = cmbRamId11.SelectedIndex + 1;

            //drDetay.RamIsi = seRamIsi11.EditValue.ToIntNN();
            //if (drDetay.RamIsi < 0)
            //    drDetay.SetRamIsiNull();

            //drDetay.FinalEn = seFinalEn11.EditValue.ToIntNN();
            //if (drDetay.FinalEn < 0)
            //    drDetay.SetFinalEnNull();

            //drDetay.IpId1 = gleIp1.EditValue.ToIntNN();
            //if (drDetay.IpId1 < 1)
            //    drDetay.SetIpId1Null();

            //drDetay.IpId2 = gleIp2.EditValue.ToIntNN();
            //if (drDetay.IpId2 < 1)
            //    drDetay.SetIpId2Null();

            //drDetay.IpId3 = gleIp3.EditValue.ToIntNN();
            //if (drDetay.IpId3 < 1)
            //    drDetay.SetIpId3Null();

            //drDetay.IpId4 = gleIp4.EditValue.ToIntNN();
            //if (drDetay.IpId4 < 1)
            //    drDetay.SetIpId4Null();

            //drDetay.Ormeci = txtOrmeci.Text;

            //drDetay.LycraId = cmbLycra.SelectedIndex + 1;
            //drDetay.OrguSekliId = cmbOrguSekli.SelectedIndex + 1;
            //drDetay.OrmeMakinesiId = gleMakineCinsi.EditValue.ToIntNN();

            //drDetay.Boyahane = txtBoyahane.Text;
            //if (drDetay.Boyahane == "")
            //    drDetay.SetBoyahaneNull();

            //drDetay.OnFikse = chkOnFikse.Checked;
            //drDetay.Yikama = chkYikama.Checked;
            //drDetay.Boya = chkBoya.Checked;
            //drDetay.KenarKesim = chkKenarKesim.Checked;


            //drDetay.Baski = txtBaski.Text;
            //if (drDetay.Baski == "")
            //    drDetay.SetBaskiNull();

            //drDetay.Baskici = txtBaskici.Text;
            //if (drDetay.Baskici == "")
            //    drDetay.SetBaskiciNull();

            //drDetay.Sanfor = chkSanfor.Checked;

            //drDetay.Firca = txtFirca.Text;
            //if (drDetay.Firca == "")
            //    drDetay.SetFircaNull();

            //drDetay.Hiz = txtHiz.Text;
            //if (drDetay.Hiz == "")
            //    drDetay.SetHizNull();

            //drDetay.KenarKola = txtKenarKola.Text;
            //if (drDetay.KenarKola == "")
            //    drDetay.SetKenarKolaNull();

            //drDetay.Parlatma = txtParlatma.Text;
            //if (drDetay.Parlatma == "")
            //    drDetay.SetParlatmaNull();

            //drDetay.BaskiTipi = txtTipi.Text;
            //if (drDetay.BaskiTipi == "")
            //    drDetay.SetBaskiTipiNull();

            //drDetay.DesenNo = txtDeseni.Text;
            //if (drDetay.DesenNo == "")
            //    drDetay.SetDesenNoNull();

            //drDetay.Cekmezlik = txtCekmezlik.Text;
            //if (drDetay.Cekmezlik == "")
            //    drDetay.SetCekmezlikNull();

            //drDetay.YikamaHasligi = txtYikamaHasligi.Text;
            //if (drDetay.YikamaHasligi == "")
            //    drDetay.SetYikamaHasligiNull();

            //drDetay.SurtHasligi = txtSurtHasligi.Text;
            //if (drDetay.SurtHasligi == "")
            //    drDetay.SetSurtHasligiNull();

            //drDetay.YikamaTalimati = txtYikamaTalimati.Text;
            //if (drDetay.YikamaTalimati == "")
            //    drDetay.SetYikamaTalimatiNull();
            //if (teQty.Visible == true)
            //    drDetay.QtyManuel = teQty.EditValue.ToDecimalNN();
        }


        private void UretimTipiChanged11()
        {
            //if (cmbUretimTipi11.SelectedIndex < 2)
            //{
            //    cmbGrup11.ReadOnly = false;
            //    cmbKompozisyon11.ReadOnly = false;
            //    seGirisGramaj11.ReadOnly = false;
            //    seFinalGramaj11.ReadOnly = false;
            //}
            //else
            //{
            //    LoadProductDetail11();
            //    cmbGrup11.ReadOnly = true;
            //    cmbKompozisyon11.ReadOnly = true;
            //    seGirisGramaj11.ReadOnly = true;
            //    seFinalGramaj11.ReadOnly = true;
            //}

            GetNewCode();
        }

        private void LoadProductDetail11()
        {
            LoadSentezDetail();

            DataSet dsProductDetail = Data.DM.ExecuteDataSet("GetProductDetail", BazProductId);

            if (dsProductDetail.Tables[0].Rows.Count == 0)
                return;

            //InitMaliyetGv(dsProductDetail.Tables[1]);

            //DataRow drDetail = dsProductDetail.Tables[0].Rows[0];
            //gleMakineCinsi.EditValue = drDetail["OrmemakinesiId"].ToIntNN();
            //cmbGrup11.SelectedIndex = drDetail["ProductGrupId"].ToComboIndex();
            //cmbKompozisyon11.SelectedIndex = drDetail["KompozisyonId"].ToComboIndex();
            //cmbRamId11.SelectedIndex = drDetail["RamId"].ToComboIndex();
            //cmbSardon11.SelectedIndex = drDetail["Sardon"].ToComboIndex();
            //cmbLycra.SelectedIndex = drDetail["LycraId"].ToComboIndex();
            //cmbOrguSekli.SelectedIndex = drDetail["OrguSekliId"].ToComboIndex();
            //txtDeseni.Text = drDetail["DesenNo"].ToStringNN();
            //seFire11.EditValue = drDetail["Fire"].ToIntNN(0);
            //seFinalEn11.EditValue = drDetail["FinalEn"].ToIntNN(0);
            //seGirisGramaj11.EditValue = drDetail["GirisGr"].ToIntNN(0);
            //seFinalGramaj11.EditValue = drDetail["FinishGr"].ToIntNN(0);
            //seRamIsi11.EditValue = drDetail["RamIsi"].ToIntNN(0);
            //gleIp1.EditValue = drDetail["IpId1"].ToIntNN();
            //gleIp2.EditValue = drDetail["IpId2"].ToIntNN();
            //gleIp3.EditValue = drDetail["IpId3"].ToIntNN();
            //gleIp4.EditValue = drDetail["IpId4"].ToIntNN();
            //txtOrmeci.Text = drDetail["Ormeci"].ToStringNN();
            //txtSıklık11.Text = drDetail["SIKLIK"].ToStringNN();
            //txtCekmezlik.Text = drDetail["Cekmezlik"].ToStringNN();
            //txtYikamaHasligi.Text = drDetail["YikamaHasligi"].ToStringNN();
            //txtSurtHasligi.Text = drDetail["SurtHasligi"].ToStringNN();
            //txtYikamaTalimati.Text = drDetail["YikamaTalimati"].ToStringNN();

            //txtBoyahane.Text = drDetail["Boyahane"].ToStringNN();
            //txtBaski.Text = drDetail["Baski"].ToStringNN();
            //txtBaskici.Text = drDetail["Baskici"].ToStringNN();
            //txtTipi.Text = drDetail["BaskiTipi"].ToStringNN();
            //txtFirca.Text = drDetail["Firca"].ToStringNN();
            //txtHiz.Text = drDetail["Hiz"].ToStringNN();
            //txtKenarKola.Text = drDetail["KenarKola"].ToStringNN();
            //txtParlatma.Text = drDetail["Parlatma"].ToStringNN();
            //txtAciklama11.Text = drDetail["Aciklama"].ToStringNN();

            //chkDink11.Checked = (bool)drDetail["Dink"];
            //chkSanfor.Checked = (bool)drDetail["Sanfor"];
            //chkBoya.Checked = (bool)drDetail["Boya"];
            //chkYikama.Checked = (bool)drDetail["Yikama"];
            //chkOnFikse.Checked = (bool)drDetail["OnFikse"];
            //chkKenarKesim.Checked = (bool)drDetail["KenarKesim"];

            //if (teQty.Visible == true)
            //    teQty.Text = drDetail["QtyManuel"].ToStringNN();
        }

        #endregion


        #region Ortak

        private void GetNewCode()
        {
            //if (bazArtikel != null)
            //{
            //    string filter = "";
            //    string result = "";

            //    int tip = 0;

            //    //20 , 10 , 30 : yıllı devam edenler , aynı form

            //    //0 , 4 , 5, 6 , 7 , 8 , 9 : 20 li formunun kullan. kodda sadece sıradaki noyu ver.


            //    if (
            //            bazArtikel.StartsWith("10") ||
            //            bazArtikel.StartsWith("11") ||
            //            bazArtikel.StartsWith("20")
            //        )
            //    {
            //        tip = 1;
            //        filter = bazArtikel.Substring(0, 3) + DateTime.Now.Year.ToString().Substring(2, 2) + "%";

            //    }
            //    else if (bazArtikel.StartsWith("30"))
            //    {
            //        tip = 2;
            //        filter = "30.%";
            //    }
            //    else if (bazArtikel.StartsWith("DT"))
            //    {
            //        tip = 3;
            //        filter = "DT.%";
            //    }
            //    else if (bazArtikel.StartsWith("DP"))
            //    {
            //        tip = 4;
            //        filter = "DP.%";
            //    }
            //    else if (bazArtikel.StartsWith("F."))
            //    {
            //        tip = 5;
            //        filter = "F.%";
            //    }
            //    else if (bazArtikel.StartsWith("4") || bazArtikel.StartsWith("5") || bazArtikel.StartsWith("6"))
            //    {
            //        tip = 6;
            //        filter = "4%";
            //    }
            //    else if (bazArtikel.StartsWith("7"))
            //    {
            //        tip = 7;
            //        filter = "7%";
            //    }
            //    else if (bazArtikel.StartsWith("8"))
            //    {
            //        tip = 8;
            //        filter = "8%";
            //    }
            //    else if (bazArtikel.StartsWith("95"))
            //    {
            //        tip = 9;
            //        filter = "95%";
            //    }
            //    else if (bazArtikel.StartsWith("9"))
            //    {
            //        tip = 10;
            //        filter = "9%";
            //    }


            //    string code = Data.DM.ExecuteScalar("GetLastCode", filter).ToStringNN();

            //    //lblYeniKod.Text = code;

            //    int no = 0;
            //    if (tip == 1)
            //    {
            //        if (code != "")
            //            no = code.Split('-')[0].Substring(5).ToIntNN();
            //        else
            //        {
            //            no = 0;
            //            code = bazArtikel.Substring(0, 2) + "." + DateTime.Now.Year.ToString().Substring(2, 2);
            //        }

            //        if (cmbUretimTipi20.SelectedIndex == 0) //aynı artikel
            //        {
            //            string lastNo = "";

            //            char c1 = bazArtikel.Substring(bazArtikel.Length - 1, 1).ToCharArray()[0];
            //            if (Char.IsDigit(c1))
            //            {
            //                char c2 = bazArtikel.Substring(bazArtikel.Length - 2, 1).ToCharArray()[0];
            //                if (Char.IsDigit(c2))
            //                    lastNo = ((c2.ToString() + c1.ToString()).ToIntNN() + 1).ToStringNN();
            //                else
            //                    lastNo = (c1.ToString().ToIntNN() + 1).ToStringNN();
            //            }
            //            else
            //                lastNo = "1";

            //            result = bazArtikel.Substring(0, 10) + lastNo;
            //        }

            //        else if (cmbUretimTipi20.SelectedIndex == 1)
            //            result = code.Substring(0, 5) + (no + 1).ToString().PadLeft(3, '0') + "-A";
            //        else if (cmbUretimTipi20.SelectedIndex == 2)
            //            result = bazArtikel.Split('-')[0] + "-" + (char)(bazArtikel.Split('-')[1].ToCharArray()[0] + 1);

            //    }
            //    else if (tip == 2)
            //    {
            //        no = code.Split('-')[0].Split('.')[1].ToIntNN();
            //        result = code.Substring(0, 3) + (no + 1).ToString().PadLeft(5, '0') + "-A";
            //    }
            //    else if (tip == 3)
            //    {
            //        no = code.Split('-')[0].Split('.')[1].ToIntNN();
            //        result = code.Substring(0, 3) + (no + 1).ToString().PadLeft(4, '0') + "-A";
            //    }
            //    else if (tip == 4)
            //    {
            //        no = code.Split('-')[0].Split('.')[1].ToIntNN();
            //        result = code.Substring(0, 3) + (no + 1).ToString().PadLeft(3, '0') + "-A";
            //    }
            //    else if (tip == 5)
            //    {
            //        no = code.Split('-')[0].Split('.')[1].ToIntNN();
            //        result = code.Substring(0, 2) + (no + 1).ToString().PadLeft(4, '0') + "-A";
            //    }
            //    else if (tip == 6 || tip == 7 || tip == 8 || tip == 9 || tip == 10)
            //    {
            //        no = code.Split('-')[0].ToIntNN();
            //        result = (no + 1).ToString().PadLeft(4, '0') + "-A";
            //    }

            //    switch (StokKartiTipi)
            //    {
            //        case 1:
            //            lblYeniKod20.Text = result;
            //            break;
            //        case 2:
            //            lblYeniKod11.Text = result;
            //            break;
            //        case 3:
            //            lblYeniKodMOI.Text = result;
            //            break;
            //        case 4:
            //            lblYeniKodDPDT.Text = result; ;
            //            break;
            //    }
            //}
        }


        private void LoadSentezDetail()
        {
            DataSet ds = null;
            try
            {
                ds = Data.DMServer.ExecuteDataSet("GetSentezArtikel", bazArtikel);
            }
            catch (Exception ex) //bağlantı yoksa!
            {
                //XtraMessageBox.Show(ex.ToString());
                ds = Data.DMLocal.ExecuteDataSet("GetSentezArtikelLocal", bazArtikel);
            }


            gcSentez.Visible = (ds.Tables[0].Rows.Count > 0);

            if (!gcSentez.Visible)
                return;

            gcSentez.Text = bazArtikel + " Sentez Detayı";

            DataRow drSK = ds.Tables[0].Rows[0];
            DataTable dt = new DataTable();
            dt.Columns.Add(Language.Sentez.Attribute, typeof(string));
            dt.Columns.Add(Language.Sentez.Value, typeof(string));

            foreach (DataColumn dc in ds.Tables[0].Columns)
                dt.Rows.Add(dc.ColumnName, drSK[dc].ToStringNN());

            gvSK.Init(dt);
            gvSK.ViewCaption = Language.Sentez.StokKarti;
            gvSK.BestFitColumns();

            gvHammadde.Init(ds.Tables[1]);
            gvHammadde.ViewCaption = Language.Sentez.Hammadde;
            gvHammadde.MakeColumnInvisible("Article");
            gvHammadde.SetCaptions("HammaddeSira:#", "Iplik:" + Language.Sentez.Hammadde, "IplikAciklama:" + Language.Sentez.Aciklama, "IplikMiktar:" + Language.Sentez.Kullanim, "Detay:" + Language.Sentez.Detail);
            gvHammadde.BestFitColumns();

            gvAciklama.Init(ds.Tables[2]);
            gvAciklama.ViewCaption = Language.Sentez.StokKartiDetayi;
            gvAciklama.MakeColumnInvisible("Article");
            gvAciklama.SetCaptions("AciklamaSira:#", "Aciklama:" + Language.Sentez.Aciklama);
            gvAciklama.BestFitColumns();
        }

        private void cmbUretimTipi_SelectedIndexChanged(object sender, EventArgs e)
        {
            //switch (StokKartiTipi)
            //{
            //    case 1:
            //        UretimTipiChanged20();
            //        break;
            //    case 2:
            //        UretimTipiChanged11();
            //        break;
            //    case 3:
            //        break;
            //    case 4:
            //        break;
            //}
        }

        private void cmbCins_SelectedIndexChanged(object sender, EventArgs e)
        {
            //int duz = 0;
            //int bukle = 0;

            //if (txtKafa1.Text != "")
            //    if (cmbCins1.SelectedIndex == 0)
            //        duz++;
            //    else
            //        bukle++;

            //if (txtKafa2.Text != "")
            //    if (cmbCins2.SelectedIndex == 0)
            //        duz++;
            //    else
            //        bukle++;

            //if (txtKafa3.Text != "")
            //    if (cmbCins3.SelectedIndex == 0)
            //        duz++;
            //    else
            //        bukle++;

            //if (txtKafa4.Text != "")
            //    if (cmbCins4.SelectedIndex == 0)
            //        duz++;
            //    else
            //        bukle++;

            ////Düz Bukle
            ////Bukle Bukle
            ////Normal Düz
            ////1 Düz-2 Bukle
            ////2 Bukle-1 Düz
            ////2 Düz-2 Bukle
            ////3 Düz-1 Bukle

            //if (duz == 1 && bukle == 1)
            //    cmbCins.SelectedIndex = 0;
            //else if (duz == 0 && bukle == 2)
            //    cmbCins.SelectedIndex = 1;

            //else if (duz == 2 && bukle == 0)
            //    cmbCins.SelectedIndex = 2;

            //else if (duz == 1 && bukle == 2)
            //    cmbCins.SelectedIndex = 3;

            //else if (duz == 1 && bukle == 2)
            //    cmbCins.SelectedIndex = 4;

            //else if (duz == 2 && bukle == 2)
            //    cmbCins.SelectedIndex = 5;

            //else if (duz == 3 && bukle == 1)
            //    cmbCins.SelectedIndex = 6;
        }
        #endregion

        private void btnKaydet_Click(object sender, EventArgs e)
        {
            //gv1.EndEditing();
            //gv2.EndEditing();
            //gv3.EndEditing();
            //gv4.EndEditing();

            //AkerDB.ProductRow drProduct = Data.DB.Product.NewProductRow();
            //if (StokKartiTipi == 1)
            //    drProduct.Article = lblYeniKod20.Text;
            //else if (StokKartiTipi == 2)
            //{
            //    drProduct.Article = lblYeniKod11.Text;
            //    if (gleIp1.EditValue.ToStringNN() == "")
            //    {
            //        XtraMessageBox.Show("1.İp boş olamaz!");
            //        return;
            //    }
            //}


            //drProduct.ModifiedBy = AppSession.UserInfo.UserId;
            //drProduct.ModifiedOn = DateTime.Now;

            //Data.DB.Product.AddProductRow(drProduct);
            //Data.SaveProduct(drProduct);

            //AkerDB.ProductDetayRow drDetay = Data.DB.ProductDetay.NewProductDetayRow();
            //drDetay.ProductId = drProduct.ProductId;

            //if (StokKartiTipi == 1)
            //{
            //    Save20(drDetay);
            //    foreach (DataRow dr in (gvMaliyet20.DataSource as DataView).Table.Rows)
            //    {
            //        AkerDB.ProductMaliyetRow drMaliyet = Data.DB.ProductMaliyet.NewProductMaliyetRow();
            //        drMaliyet.ProductId = drProduct.ProductId;//BazProductId;
            //        drMaliyet.Aciklama = dr["MaliyetAciklama"].ToStringNN();
            //        drMaliyet.CurrencyId = dr["CurrencyId"].ToIntNN();
            //        drMaliyet.Fiyat = dr["Fiyat"].ToDecimalNN();
            //        Data.DB.ProductMaliyet.Rows.Add(drMaliyet);
            //        Data.TAM.ProductMaliyetTableAdapter.Update(drMaliyet);
            //    }
            //}
            //else if (StokKartiTipi == 2)
            //{
            //    Save11(drDetay);
            //    foreach (DataRow dr in (gvMaliyet11.DataSource as DataView).Table.Rows)
            //    {
            //        AkerDB.ProductMaliyetRow drMaliyet = Data.DB.ProductMaliyet.NewProductMaliyetRow();
            //        drMaliyet.ProductId = drProduct.ProductId;// BazProductId;
            //        drMaliyet.Aciklama = dr["MaliyetAciklama"].ToStringNN();
            //        drMaliyet.CurrencyId = dr["CurrencyId"].ToIntNN();
            //        drMaliyet.Fiyat = dr["Fiyat"].ToDecimalNN();
            //        Data.DB.ProductMaliyet.Rows.Add(drMaliyet);
            //        Data.TAM.ProductMaliyetTableAdapter.Update(drMaliyet);
            //    }
            //}




            //Data.DB.ProductDetay.Rows.Add(drDetay);
            //Data.TAM.ProductDetayTableAdapter.Update(drDetay);

            //btnKaydet.Enabled = false;

            //if (ProductInserted != null)
            //    ProductInserted(drProduct.ProductId, drProduct.Article, StokKartiTipi);

            //AppSession.MainForm.ShowMdiChildForm(typeof(ImalatKartlari), drProduct.ProductId);
        }

        private void gleMakineCinsi_EditValueChanged(object sender, EventArgs e)
        {
            //if (gleMakineCinsi.EditValue.ToIntNN() != -1)
            //{
            //    DataTable dt = Data.DB.OrmeMakinesi.Select("OrmeMakinesiId=" + gleMakineCinsi.EditValue).CopyToDataTable();
            //    txtPus.Text = dt.Rows[0]["PUS"].ToStringNN();
            //    txtFayn.Text = dt.Rows[0]["Fine"].ToStringNN();
            //    txtSistem.Text = dt.Rows[0]["Sistem"].ToStringNN();
            //}
        }
 

        private void gleBazArtikel11_EditValueChanged(object sender, EventArgs e)
        {
            //BazProductId = gleBazArtikel11.EditValue.ToIntNN();
            //Load11();
        }
    }
}